<template>
	<view>
		<u-navbar :is-back="false" title="" :border-bottom="false">
			<view class="slot-wrap">
				<view class="back" @click="navTo('back')">
					<view class="iconfont iconfanhui" :style="{'padding-top': paddingTop}"></view>
					<view class="text">返回</view>
				</view>
				<view class="set">问题反馈</view>
				<view class="save" @click="navTo('save')">提交</view>
			</view>
		</u-navbar>
		<view class="content">
			<textarea maxlength="200" placeholder-style="color:#b4b4b4" placeholder="如果您对于安瑞律师的功能问题有任何疑问，请在此处留言反馈。" v-model="content"/>
			<view class="max-len">{{ content.length }}/200字</view>
		</view>
	</view>
</template>

<script>
	import { suggest } from '@/api/userApi.js'
	export default {
		data() {
			return {
				tips: '',
				seconds: 10,
				paddingTop: '2rpx',
				content: '',
				savaOnce: true
			}
		},
		onLoad() {
			if(uni.getSystemInfoSync().platform != "ios") {
				this.paddingTop = '8rpx'
			}
		},
		methods: {
			async navTo(data) {
				if (data === 'back') {
					uni.navigateBack()
				} else if (data === 'save'){
					
					if (this.content.length == 0) return this.$u.toast('请输入内容')
					if (this.savaOnce) {
						const res = await suggest({content: this.content})
						this.$u.toast('提交成功')
						setTimeout(() => {
							uni.navigateBack()
						}, 1000)
						this.savaOnce = false
					} else {
						this.$u.toast('请勿重复提交')
					}
					
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #fff;
	}
	.slot-wrap {
		display: flex;
		align-items: center;
		flex: 1;
		padding: 0 30rpx;
		.back {
			display: flex;
			font-size: 32rpx;
			.iconfanhui {
				font-weight: bold;
				font-size: 36rpx;
			}
		}
		.set {
			display: flex;
			margin-left: 26%;
			font-weight: bold;
			font-size: 32rpx;
		}
		.save {
			margin-left: auto;
			font-size: 32rpx;
		}
	}
	.content {
		margin: 30rpx;
		position: relative;
		textarea {
			background-color: #f9f9f9;
			height: 400rpx;
			width: 94%;
			border-radius: 20rpx;
			padding: 20rpx;
		}
		.max-len {
			position: absolute;
			right: 30rpx;
			bottom: 20rpx;
			font-size: 24rpx;
			color:#b4b4b4;
		}
	}
	.uni-textarea-compute, .uni-textarea-line, .uni-textarea-placeholder, .uni-textarea-textarea {
		width: 100% !important;
	}
</style>
